Random Tunnel Generator

Hans-Peter Klett

Tunnels

What it is

Those are random tunnels. They are separated into segments, as is apparent in the picture, and joined by toruses. The tunnels are generated using four splines per segment (as can be seen by the different coloring).

Each spline is a two parameters, going into a cubic and a quadratic bezier function. The initial control points for each of the four splines is hard-coded. The remaining two sets of control points are computed by making OpenGL transformations, and saving the resulting matrix to an array. The array is then multiplied using a custom function by each control point to create the addition control points.

The four pieces are there because four cubic splines approximates a circle much better than a 5th order spline. The reference cited was REALLY helpful, because the explanation was followed by a really huge THIS IS THE NUMBER YOU NEED.

There are a constant number of segments. Each segment is created by picking a random point outside the start circle, and rotating by a random angle around the first control points to a middle and end set of control points.

In order to line up the tunnels, the transformation that was used to make the end control points is re-used to move the next segment to the end of current.

References

  1. http://www.tinaja.com/glib/ellipse4.pdf